package com.qijian.maindata.domain.query;

import com.baomidou.mybatisplus.annotation.TableName;
import com.qijian.common.enums.ApprovalDescriptionEnum;
import com.qijian.common.utils.mybatis.WhereType;
import com.qijian.common.utils.mybatis.WhereTypeEnum;
import lombok.Data;
import lombok.ToString;

import java.util.Date;
import java.util.Set;

/**
 * 生产BOM对象 查询条件类
 *
 * @author qijian
 * @date 2021-09-01
 */

@Data
@ToString
@TableName("main_bom")
public class BomQuery {

    @WhereType(filed = "bom_id")
    private Long bomId;
    @WhereType(filed = "bom_id", type = WhereTypeEnum.IN)
    private Set<Long> bomIds;
    @WhereType(filed = "bom_code")
    private String bomCode;
    @WhereType(filed = "user_id")
    private Long userId;
    @WhereType(filed = "nick_name", type = WhereTypeEnum.LIKE)
    private String nickName;
    @WhereType(filed = "bom_version")
    private String bomVersion;
    @WhereType(filed = "item_id")
    private Long itemId;
    @WhereType(filed = "item_code", type = WhereTypeEnum.LIKE)
    private String itemCode;
    @WhereType(filed = "item_code_eq", type = WhereTypeEnum.LIKE)
    private String itemCodeEq;
    @WhereType(tableName = "main_item", filed = "item_name", type = WhereTypeEnum.LIKE)
    private String itemName;
    @WhereType(tableName = "main_item", filed = "item_classify")
    private String itemClassify;
    @WhereType(filed = "is_disabled")
    private Boolean isDisabled;
    @WhereType(deptTableName = "u", userTableName = "main_bom")
    private Boolean dataScope;

    @WhereType(filed = "bom_id", type = WhereTypeEnum.IN)
    private Set<Long> ids;

    @WhereType(filed = "approval_status", type = WhereTypeEnum.NEQ)
    private ApprovalDescriptionEnum neqApprovalStatus;

    @WhereType(filed = "create_time", sort = true)
    private Date createTime;


    @WhereType(filed = "id", tableName = "sys_classify", func = "find_in_set( {1} , sys_classify.ancestors )")
    private Long classifyId;

    @WhereType(func = "(bom_status -> \"$.BOM\" = FALSE OR bom_status -> \"$.线路\" = FALSE OR bom_status -> \"$.定额\" = FALSE OR bom_status -> \"$.数控件\" = FALSE)")
    private Boolean isCheck;

    @WhereType(func = "( main_bom.quality_engineer_id IS NULL )")
    private Boolean qualityManagementExists;


    @WhereType(fields = {"main_bom.nick_name", "main_bom.item_code", "main_item.item_name", "main_bom.bom_type","main_bom.quality_engineer_name"}, type = WhereTypeEnum.LIKE)
    private String condition;

    @WhereType(func = "( main_bom.quality_engineer_name IS null or main_bom.quality_engineer_name = '' )")
    private Boolean qualityManagementNotExistsNew;


    @WhereType(func = "(main_bom.bom_type = 1 and  main_item.item_code not like '%BL%' ) ")
    private Boolean qualityManagementGzFilter;

    @WhereType(ignore = true)
    private String transferFromPage;

    @WhereType(ignore = true)
    private Integer queryDays;

    @WhereType(ignore = true)
    private String lstTime;
}
